﻿using BusinessObjects;
using Domain.Abstract;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace WebUI.Controllers
{
    public class XaPhuongController : Controller
    {
        private IXaPhuongRepository _xaPhuongRepository;

        public XaPhuongController(IXaPhuongRepository xaPhuongRepository)
        {
            _xaPhuongRepository = xaPhuongRepository;
        }

        public JsonResult GetXaPhuongsByQuanHuyenId(int quanHuyenId)
        {
            var lstXaPhuong = _xaPhuongRepository.GetXaPhuongsByQuanHuyenId(quanHuyenId).Select(x => new { x.Id, x.Ten }).OrderBy(x => x.Ten);

            return Json(lstXaPhuong, JsonRequestBehavior.AllowGet);
        }
    }
}
